
* Set working directory to the folder where the files are stored

* Table 1
* Opinion Level data

use "Opiniondata.dta", clear

tab TypeWBDissent ProGov



*Figure 1
*Grand Chamber Level Data
use  "FinalDataGCLevel.dta", clear
keep if Outcome>0
 
 replace Outcome=0 if Outcome==2
 
 gen Outcomeb=Outcome
 
  gen opinion3b=opinion3
  gen sepproappb=sepproapp
  gen sepprogovb=sepprogov
 
 collapse (sum) Outcome opinion3 sepprogov sepproapp (mean) Outcomeb opinion3b sepprogovb sepproappb, by(period)
  

replace opinion3b=opinion3b*100
replace Outcomeb=Outcomeb*100

label define vl 1 "1999–2005" 2 "2006–2011" 3 "2012–2018"
label values period vl

*Figure1
 twoway (connected Outcome period, msize(large)  msize(large) mfcolor(black)) (connected Outcomeb period, msize(large) lpattern(dash)  mcolor(blue) mfcolor(blue) lcolor(blue)), legend(order(1 "Number of cases" 2 "Percentage of cases")) ///
 scheme(plotplainblind) xtitle(Period) xlabel(#3, valuelabel) 
 graph export "Figure1.png", as(png) replace

  
  *Figure2
use  "FinalDataGCLevel.dta", clear
  sort period
by period: egen sepproappS=sum(sepproapp)
by period: egen sepproappP=mean(sepproapp)

replace sepproappP=sepproappP*100

by period: egen sepprogovS=sum(sepprogov)
by period: egen sepprogovP=mean(sepprogov)

replace sepprogovP=sepprogovP*100

tab  sepprogovS period, row


label define vl 1 "1999–2005" 2 "2006–2011" 3 "2012–2018"
label values period vl

  twoway (connected sepproappS period, msize(large)  msize(large) mfcolor(black)) (connected sepproappP period, msize(large) lpattern(dash)  mcolor(blue) mfcolor(blue) lcolor(blue)), legend(order(1 "Number of judgments" 2 "% of judgments") size(small) )  ///
 scheme(plotplainblind) xtitle(Period) xlabel(#3, valuelabel) 
 
  graph export "Figure2.png", as(png) replace
  
*Regression Analyses (table1 isfrom the article)
use  "FinalDataGCLevel.dta", clear

split Articles, parse(;) gen(art) 

gen article3=0
gen article14=0
gen article8=0
gen article10=0
gen P1=0
gen article6=0
gen article61=0
gen article5=0
gen article2=0
gen article12=0
gen article4=0
gen article9=0
gen article16=0
gen article62=0
gen article63=0
gen P12=0

gen article34=0


foreach x of varlist art1-art30 {
replace article2=1 if `x'=="2"
replace article3=1 if `x'=="3"
replace article4=1 if `x'=="4"
replace article5=1 if `x'=="5"
replace article6=1 if `x'=="6"
replace article8=1 if `x'=="8"
replace article9=1 if `x'=="9"
replace article10=1 if `x'=="10"
replace article12=1 if `x'=="12"
replace article14=1 if `x'=="14"
replace article16=1 if `x'=="16"
replace article61=1 if `x'=="6-1"
replace article62=1 if `x'=="6-2"
replace article63=1 if `x'=="6-3"
replace article34=1 if `x'=="34"
replace P1=1 if `x'=="P1-1"
replace P12=1 if `x'=="P1-2"
}

gen importance=0
replace importance=1 if ImportanceLevel=="1"
replace importance=2 if ImportanceLevel=="2"
replace importance=3 if ImportanceLevel=="3"

label define vl2 1 "1" 2 "2" 3 "3"
label values importance vl2

gen importance2=0
replace importance2=1 if ImportanceLevel=="1"
replace importance2=1 if ImportanceLevel=="2"
replace importance2=1 if ImportanceLevel=="3"
label define vl3 0 "Case Reports" 1 "1-3" 
label values importance vl3

merge m:1 RespondentStates using "C:\Users\ev42\Dropbox\WalkingBackHumanRights\Data\FinalData\ConsolidatedDemocracy.dta"

gen art2358=0
replace art2358=1 if article2==1 | article3==1 | article5==1 | article8==1
sort art2358
by art2358: tab period sepproapp, col

* Determinants of sepproapp
reg sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1 
outreg2 using table1.doc,  dec(2) replace

reg sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1  democracy 
outreg2 using table1.doc,  dec(2) append

reg sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1  democracy prisoner refugee i.importance
outreg2 using table1.doc,  dec(2) append

logit sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1 
outreg2 using table2.doc,  dec(2) replace

logit sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1  democracy 
outreg2 using table2.doc,  dec(2) append

logit sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1  democracy prisoner refugee i.importance
outreg2 using table2.doc,  dec(2) append

logit sepproapp i.period   violation article2 article3 article5 article6 article8 article10 P1  democracy prisoner refugee i.importance2
outreg2 using table2.doc,  dec(2) append


reg sepprogov i.period  violation article2 article3 article5 article6 article8 article10 P1 democracy
outreg2 using table1.doc,  dec(2) append

* Determinants of sepproapp
reg sepproapp i.period  i.importance violation article2 article3 article5 article6 article8 article10 P1 
outreg2 using table1.doc,  dec(2) replace

reg sepprogov i.period  i.importance violation article2 article3 article5 article6 article8 article10 P1 
outreg2 using table1.doc,  dec(2) append


reg sepproapp democracy##i.period  i.importance violation  article2 article3 article5 article6 article8 article10 P1 
outreg2 using table1.doc,  dec(2) append

reg sepprogov democracy##i.period  i.importance violation article2 article3 article5 article6 article8 article10 P1
outreg2 using table1.doc,  dec(2) append

  